/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author edgar
 */
@Entity
@Table(name = "ordenes_detalle")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OrdenesDetalle.findAll", query = "SELECT o FROM OrdenesDetalle o"),
    @NamedQuery(name = "OrdenesDetalle.findByCodOrden", query = "SELECT o FROM OrdenesDetalle o WHERE o.ordenesDetallePK.codOrden = :codOrden"),
    @NamedQuery(name = "OrdenesDetalle.findByCodCliente", query = "SELECT o FROM OrdenesDetalle o WHERE o.ordenesDetallePK.codCliente = :codCliente"),
    @NamedQuery(name = "OrdenesDetalle.findByNroLinea", query = "SELECT o FROM OrdenesDetalle o WHERE o.ordenesDetallePK.nroLinea = :nroLinea"),
    @NamedQuery(name = "OrdenesDetalle.findByCantidad", query = "SELECT o FROM OrdenesDetalle o WHERE o.cantidad = :cantidad"),
    @NamedQuery(name = "OrdenesDetalle.findByPrecio", query = "SELECT o FROM OrdenesDetalle o WHERE o.precio = :precio")})
public class OrdenesDetalle implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected OrdenesDetallePK ordenesDetallePK;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "cantidad")
    private Float cantidad;
    @Column(name = "precio")
    private Integer precio;
    @JoinColumn(name = "cod_cliente", referencedColumnName = "cod_cliente", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Clientes clientes;
    @JoinColumn(name = "cod_articulo", referencedColumnName = "cod_articulo")
    @ManyToOne
    private Articulos codArticulo;

    public OrdenesDetalle() {
    }

    public OrdenesDetalle(OrdenesDetallePK ordenesDetallePK) {
        this.ordenesDetallePK = ordenesDetallePK;
    }

    public OrdenesDetalle(int codOrden, int codCliente, int nroLinea) {
        this.ordenesDetallePK = new OrdenesDetallePK(codOrden, codCliente, nroLinea);
    }

    public OrdenesDetallePK getOrdenesDetallePK() {
        return ordenesDetallePK;
    }

    public void setOrdenesDetallePK(OrdenesDetallePK ordenesDetallePK) {
        this.ordenesDetallePK = ordenesDetallePK;
    }

    public Float getCantidad() {
        return cantidad;
    }

    public void setCantidad(Float cantidad) {
        this.cantidad = cantidad;
    }

    public Integer getPrecio() {
        return precio;
    }

    public void setPrecio(Integer precio) {
        this.precio = precio;
    }

    public Clientes getClientes() {
        return clientes;
    }

    public void setClientes(Clientes clientes) {
        this.clientes = clientes;
    }

    public Articulos getCodArticulo() {
        return codArticulo;
    }

    public void setCodArticulo(Articulos codArticulo) {
        this.codArticulo = codArticulo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ordenesDetallePK != null ? ordenesDetallePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrdenesDetalle)) {
            return false;
        }
        OrdenesDetalle other = (OrdenesDetalle) object;
        if ((this.ordenesDetallePK == null && other.ordenesDetallePK != null) || (this.ordenesDetallePK != null && !this.ordenesDetallePK.equals(other.ordenesDetallePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.OrdenesDetalle[ ordenesDetallePK=" + ordenesDetallePK + " ]";
    }
    
}
